package com.zoo.diannaopeijian.service;

import com.zoo.diannaopeijian.common.page.Page;
import com.zoo.diannaopeijian.domain.Stock;
import com.zoo.diannaopeijian.domain.Ware;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * 库存服务
 */
public interface StockService {
    /**
     * 新增库存
     *
     * @param stock
     * @return
     */
    boolean insertStock(Stock stock);

    /**
     * 增加库存
     *
     * @param stock
     * @return
     */
    boolean increaseStock(Stock stock);

    /**
     * 减少库存
     *
     * @param stock
     * @return
     */
    boolean reduceStock(Stock stock);

    /**
     * 批量减少库存
     *
     * @param stockList
     * @return
     */
    @Transactional(propagation= Propagation.REQUIRES_NEW)
    boolean reduceStocks(List<Stock> stockList);

    /**
     * 批量增加库存
     *
     * @param stockList
     * @return
     */
    @Transactional(propagation= Propagation.REQUIRES_NEW)
    boolean increaseStocks(List<Stock> stockList);

    /**
     * 更新库存
     *
     * @param stock
     * @return
     */
    boolean updateStock(Stock stock);

    /**
     * 获取商品库存
     *
     * @param componentId
     * @param componentParameterDetailIds
     * @param repertoryId
     * @param ware
     * @return 商品库存(拓展对象)
     */
    List<Map> getWareStock(Integer componentId,
                           List<Integer> componentParameterDetailIds,
                           Integer repertoryId,
                           Ware ware
    );

    /**
     * 分页获取商品库存
     *
     * @param page
     * @param componentId
     * @param componentParameterDetailIds
     * @param repertoryId
     * @param ware
     * @return 商品库存(拓展对象)
     */
    List<Map> getWareStockWithPage(Page page, Integer componentId,
                                   List<Integer> componentParameterDetailIds,
                                   Integer repertoryId,
                                   Ware ware);

    /**
     * 模糊查询获取商品库存
     *
     * @param componentId
     * @param componentParameterDetailIds
     * @param repertoryId
     * @param ware
     * @return 商品库存(拓展对象)
     */
    List<Map> getFuzzyWareStock(Integer componentId,
                                List<Integer> componentParameterDetailIds,
                                Integer repertoryId,
                                Ware ware);

    /**
     * 分页模糊查询获取商品库存
     *
     * @param page
     * @param componentId
     * @param componentParameterDetailIds
     * @param repertoryId
     * @param ware
     * @return 商品库存(拓展对象)
     */
    List<Map> getFuzzyStockWithPage(Page page, Integer componentId,
                                    List<Integer> componentParameterDetailIds,
                                    Integer repertoryId,
                                    Ware ware);

    /**
     * 获取库存数
     *
     * @param stock
     * @return
     */
    Integer getStockNum(Stock stock);
}
